Skip to content

Conversation

@cpatino-intive
Copy link
Contributor

MPC consolidation
TASK: WP-5170

@cpatino-intive cpatino-intive force-pushed the WP-5170/mpc-consolidation-refactor branch from 3f959f5 to 87d9bd8 Compare July 10, 2025 14:29
Base automatically changed from WP-5232-mpcv2-signing-custom-fns to master July 10, 2025 16:23
Copy link
Contributor

@pranavjain97 pranavjain97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall lgtm; small nits

throw new Error('consolidateAddresses must be an array of addresses');
}

const isMPC = wallet._wallet.multisigType === 'tss';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const isMPC = wallet._wallet.multisigType === 'tss';
const isMPC = wallet.multisigType() === 'tss';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

msg = `Consolidations failed: ${failedTxs.length} and succeeded: ${successfulTxs.length}`;
} else {
// All failed
status = 400;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be a 500. 400 is if it fails due to an error from user input

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@pranavjain97 pranavjain97 requested a review from Copilot July 11, 2025 18:11
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the account consolidation flow to support both onchain multisig and MPC (TSS) wallets, introduces a commonKeychain parameter, and updates the API spec and tests.

  • Add optional commonKeychain to the ConsolidateRequest spec and validate it in handlerUtils.
  • Refactor handleConsolidate to loop through builds, collect per-build success/failure, and branch between sendAccountConsolidation and signAndSendTxRequests.
  • Export signAndSendMultisig, update API JSON (masterBitgoExpress.json) with a new accelerate endpoint, and adapt tests for the new consolidation logic.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/api/master/routers/masterApiSpec.ts Added commonKeychain as an optional field in ConsolidateRequest
src/api/master/handlers/handleSendMany.ts Made signAndSendMultisig an exported function
src/api/master/handlers/handleConsolidate.ts Complete overhaul to handle MPC vs. multisig consolidation and result handling
src/api/master/handlerUtils.ts Extended getWalletAndSigningKeychain to accept and validate commonKeychain
src/tests/api/master/consolidate.test.ts Updated and expanded tests for both multisig and MPC consolidation flows
masterBitgoExpress.json Added /accelerate endpoint and included commonKeychain in spec
Comments suppressed due to low confidence (5)

src/api/master/handlerUtils.ts:20

  • Update the JSDoc/comments for getWalletAndSigningKeychain to describe the new commonKeychain parameter and its purpose.
  params: { source: 'user' | 'backup'; pubkey?: string; commonKeychain?: string };

src/tests/api/master/consolidate.test.ts:12

  • The test suite title references consolidateunspents but the endpoint under test is /consolidate; please correct the describe string to match the actual route.
describe('POST /api/:coin/wallet/:walletId/consolidateunspents', () => {

src/api/master/handlers/handleConsolidate.ts:38

  • [nitpick] The request spec marks consolidateAddresses as optional, but this validation rejects undefined values. Decide whether missing addresses should default to full consolidation or update the spec to make it required.
    throw new Error('consolidateAddresses must be an array of addresses');

masterBitgoExpress.json:9

  • [nitpick] The new accelerate endpoint appears unrelated to MPC consolidation; consider splitting it into its own PR or providing additional context.
    "/api/{coin}/wallet/{walletId}/accelerate": {

src/api/master/handlers/handleSendMany.ts:195

  • [nitpick] The signAndSendMultisig function was made exported but isn’t referenced elsewhere; remove the export if it’s unused or update imports to leverage it where appropriate.
export async function signAndSendMultisig(

Copy link
Contributor

@mohammadalfaiyazbitgo mohammadalfaiyazbitgo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please address comments in a follow up.

Comment on lines +116 to +119
(error as any).result = {
success: successfulTxs,
failure: failedTxs,
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please avoid any when you can.

@pranavjain97 pranavjain97 merged commit 00da6c0 into master Jul 14, 2025
3 checks passed
@pranavjain97 pranavjain97 deleted the WP-5170/mpc-consolidation-refactor branch July 14, 2025 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants